import React from 'react';
import { useState } from 'react'
// 导入子组件
import Son from './Son';
// 引入context对象
import contextObj from './context';
console.log('contextObj', contextObj);
const { Provider } = contextObj
const Father = () => {
    const [user, setUser] = useState({ name: '铁拐李', age: 50 })
    return (
        <div>
            {/* 使用子组件 */}
            <p>我是父亲组件--<button onClick={() => {
                setUser({
                    ...user,
                    age: user.age + 1
                })
            }}  >年龄++</button></p>
            <Provider value={user}>
                <Son></Son>
            </Provider>

        </div>
    );
}

export default Father;
